class Solution {
public:
    string stolow(string s) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 32;
        }
        return s;
    }

    string delyuan(string s) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') s[i] = ' ';
        }
        return s;
    }

    vector<string> spellchecker(vector<string>& wordlist, vector<string>& queries) {
        unordered_map<string, string> hash1, hash2, hash3;
        for (int i = 0; i < wordlist.size(); i++) {
            hash1[wordlist[i]] = wordlist[i];
            string tmp = stolow(wordlist[i]);
            if (hash2.find(tmp) == hash2.end()) hash2[tmp] = wordlist[i];
            string tmpy = delyuan(tmp);
            if (hash3.find(tmpy) == hash3.end()) hash3[tmpy] = wordlist[i];
        }

        vector<string> ret(queries.size(), "");
        for (int i = 0; i < queries.size(); i++) {
            string tmp = stolow(queries[i]);
            string tmpy = delyuan(tmp);
            if (hash1.find(queries[i]) != hash1.end()) ret[i] = queries[i];
            else if (hash2.find(tmp) != hash2.end()) ret[i] = hash2[tmp];
            else if (hash3.find(tmpy) != hash3.end()) ret[i] = hash3[tmpy];
        }
        return ret;
    }
};